<!DOCTYPE HTML>
<html>
 <head>
  <title> New Document </title>
  <meta name="" content="">
 </head>

 <body>
  <input type="text" value='' id='link' /> <input id='linkBut' type="button" value='链接' /><br/>
  <input type="text" value='{userId:UNDQ2NjYyMzA0,name:shangwenhe,client:pc,mark:test}' id='submit' /> <input id='submitBut' type="button" value='提交' /><br/>
  <script type="text/javascript">
  
//setInterval(function(){
	  
	var socket = null;
	var userId = 0;
	var linkBut = document.querySelector('#linkBut');
		//linkBut.addEventListener('click',function(){
			socket = new WebSocket('ws://test.youku.com:9000');


			socket.onopen = function(){
               console.log('onopen');
            }

			socket.onmessage = function(e){
                console.log(e.data);
            }
		
	//	},false);

//	var submitBut = document.querySelector('#submitBut');
//	var submit = document.querySelector('#submit');
//		submitBut.addEventListener('click',function(){
//			socket.send( submit.value);
//		},false);
		userId++;

		var i = 0;
		setInterval(function(){
				var message = 'mysent:'+( i++);
				var MessageJson = {
					username:'guest',
					color:'green',
					message: message ,
					userId: userId
					 }
				socket.send( JSON.stringify(MessageJson));
			
			},10)

//	  },5000)



  </script>
 </body>
</html>

